package demo1;

import java.util.Arrays;

class Shape{
    public void draw(){
        System.out.println("Shape::draw()");
    }
}

class Rect extends Shape{
    @Override
    public void draw(){
        System.out.println("方块♦");
    }
}

class Flower extends Shape{
    @Override
    public void draw() {
        System.out.println("花❀");
    }
}

class Triangle extends Shape{
    @Override
    public void draw(){
        System.out.println("三角形△");
    }
}

class Cycle extends Shape{
    @Override
    public void draw(){
        System.out.println("圆○");
    }
}

public class Test {

    public static void main4(String[] args) {
        Rect rect = new Rect();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();

        Shape[] shapes = {triangle,rect,triangle,rect,flower};
        for (Shape s:shapes) {
            s.draw();
        }
    }

    public static void main3(String[] args) {
        Rect rect = new Rect();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();
        String[] shapes = {"triangle", "rect", "triangle", "rect", "flower"};
        for (String s: shapes) {
            if(s.equals("triangle")){
                triangle.draw();
            }else if(s.equals("rect")){
                rect.draw();
            }else {
                flower.draw();
            }
        }
    }

    public static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main2(String[] args) {
        Rect rect = new Rect();
        drawMap(rect);
        Flower flower = new Flower();
        drawMap(flower);
        drawMap(new Triangle());
    }

    public static void main1(String[] args) {
        Rect rect = new Rect();
        rect.draw();

        Shape shape1 = new Rect();
        shape1.draw();

        Shape shape2 = new Flower();
        shape2.draw();
    }
}
